package fr.ece.ing4.si.rockpaperscissors;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.Random;


public class Player
{
	// Attributes
	private int score;
	private String playerName;
	private List<RPSEnum> playerMovesList;
	private ListIterator<RPSEnum> listIterator;
	
	
	/**
	 * Overloading constructor
	 * @param playerName
	 * @param playerMovesList
	 */
	public Player(String playerName, List<RPSEnum> playerMovesList)
	{
		score = 0;
		this.playerName = playerName;
		this.playerMovesList = playerMovesList;
		
		listIterator = this.playerMovesList.listIterator();
	}
	
	
	/**
	 * Overloading constructor
	 * @param playerName
	 */
	public Player(String playerName)
	{
		score = 0;
		
		this.playerName = playerName;
		
		Random rand = new Random();
		
		playerMovesList = new ArrayList<RPSEnum>(10);
		
		for (int i = 0; i < playerMovesList.size(); i++)
		{
			int randomPlayerMove = rand.nextInt(3);
			
			switch(randomPlayerMove)
			{
				default:
					break;
					
				case 0:
					playerMovesList.add(RPSEnum.ROCK);
					break;
					
				case 1:
					playerMovesList.add(RPSEnum.PAPER);
					break;
					
				case 2:
					playerMovesList.add(RPSEnum.SCISSORS);
					break;
			}
		}
	}
	
	
	/**
	 * Getter to attribute score of class Player
	 * @return score of the player
	 */
	public int getScore()
	{
		return score;
	}
	
	/**
	 * Setter to attribute score of class Player
	 * @param score
	 */
	public void setScore(int score)
	{
		this.score = score;
	}
	
	/**
	 * Getter to attribute playerName of class Player
	 * @return name of the player
	 */
	public String getPlayerName()
	{
		return playerName;
	}
	
	/**
	 * Getter to the fixed number of RPSEnum elements of the list playerMovesList
	 * @return the fixed number of RPSEnum elements of playerMovesList
	 */
	public int getPlayerMovesListSize()
	{
		return playerMovesList.size();
	}
	
	/**
	 * Getter to the next element of the list playerMovesList
	 * @return the next element of the list playerMovesList
	 */
	public RPSEnum getNextMove()
	{
		return listIterator.next();
	}
}
